package com.yang.config;

import com.yang.intercepter.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author: 不是菜鸡爱编程
 * @Date: 2024/02/17/11:55
 * @Description:
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 添加拦截器
        registry.addInterceptor(loginInterceptor)
                // 添加拦截路径
                .addPathPatterns("/**")
                // 配置排除路径
                .excludePathPatterns("/favicon.ico","/user/login", "/user/register","/user/captcha/**","/file/download/**",
                        "/swagger-ui/**","/swagger-resources/**","/v3/api-docs","/error","/websocket/**");
    }
}
